/**
 * Created by X250 on 2017/5/16.
 */
public class BubbleSort {
    public static void bubbleSort(){
        int a[]={49,38,65,97,76,13,27,49};
        int temp=0;
        for(int i=0;i<a.length-1;i++){
            for(int j=0;j<a.length-1-i;j++){
                if(a[j]>a[j+1]){
                    temp=a[j];
                    a[j]=a[j+1];
                    a[j+1]=temp;
                }
            }
            System.out.println("第"+ i +"趟排序后的结果：");
           printArr(a);
        }
        System.out.println("最终排序后的结果：");
        printArr(a);
    }

    public static void printArr(int[] numbers)
    {
        for(int i = 0 ; i < numbers.length ; i ++ )
        {
            System.out.print(numbers[i] + ",");
        }
        System.out.println("");
    }

    public static void main(String[] args){
        bubbleSort();
    }
}
